[I want to]
interface T {
a?: string;
b?: number;
c?: boolean;
d?: object;
e?: null;
}
type A = {
a: string;
b: number;
q: string; // not exist in type T
}
type B = {
a: string;
b: number;
}
type G<U extends T> = {
data: U;
creator: () => void;
}
const someFunc = <U>(data: U): G<U> => {
return {
data,
creator: () => { console.log(data ) }
}
}
const funcA = (data: A) => {
const something = someFunc<A>(data); // I want to occur error
}
const funcB = (data: B) => {
const something = someFunc<B>(data); // I want to do well
}
Type 'T' has optional property ( every property ).
One type is subset of type "T" ( is "B" )
Another one is not subset of type "T" ( is "A" - has property "q" )
But, using type "B" is not occured error.
How to do?
Thank you.