Open2024/11/26にコメント追加5Negated typesTypeScriptken72532024/11/17https://github.com/microsoft/TypeScript/issues/4196 返信を追加ken72532024/11/21に更新こういうふうにすると特定の値を除外できるらしい。 https://www.typescriptlang.org/play/?#code/GYVwdgxgLglg9mABMOcA8EEGcqICqICmAHlIWACZaJggC2ARoQE4B8AFLXQFyICixCABsQFQmjwAaRAAZWASgDeAKERrEzQlBDMkXRACpEAJgDcygL7nlmMDkQBDRAF5kqdjPmmgA function foo<const T extends number>(num: Exclude<T, 0>){ return num * 2; }; const a = foo(0); 返信を追加ken72532024/11/22https://github.com/microsoft/TypeScript/issues/4196#issuecomment-1601404332 Apologies, this one was mis-tagged. Negated types are still "on the table" so to speak. ken72532024/11/26実際に実装してみようとしたPR https://github.com/microsoft/TypeScript/pull/29317 返信を追加ken72532024/11/26に更新 他言語での否定型 返信を追加
ken72532024/11/21に更新こういうふうにすると特定の値を除外できるらしい。 https://www.typescriptlang.org/play/?#code/GYVwdgxgLglg9mABMOcA8EEGcqICqICmAHlIWACZaJggC2ARoQE4B8AFLXQFyICixCABsQFQmjwAaRAAZWASgDeAKERrEzQlBDMkXRACpEAJgDcygL7nlmMDkQBDRAF5kqdjPmmgA function foo<const T extends number>(num: Exclude<T, 0>){ return num * 2; }; const a = foo(0); 返信を追加
ken72532024/11/22https://github.com/microsoft/TypeScript/issues/4196#issuecomment-1601404332 Apologies, this one was mis-tagged. Negated types are still "on the table" so to speak. ken72532024/11/26実際に実装してみようとしたPR https://github.com/microsoft/TypeScript/pull/29317 返信を追加