We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--strictAny
#24423
Talked about this last time, but no implementation.
Now we have an implementation and data.
Came from conversation with the Hack team.
Background: problem today is that any is assignable in both directions.
any
.d.ts
Tried running --strictAny on DefinitelyTyped
Not on tests - tests have too much breakage.
Some things got broken - declaration files were
Much of the time it's just declaration authors being a little lazy.
prototype
Why is any not assignable to Record<string, any>>
Record<string, any>
There are some issues with signatures like (x: any, y: any, ...zs: any[]) => any.
(x: any, y: any, ...zs: any[]) => any
never
Issues with SVGElement not being assignable to Element.
SVGElement
Element
Then there's the "covariant event emitter pattern".
once(event: string, listener: (...args: any[]) => void): this; once(event: "close", listener: () => void): this; once(event: "drain", listener: () => void): this; once(event: "error", listener: (err: Error) => void): this; once(event: "finish", listener: () => void): this; once(event: "pipe", listener: (src: Readable) => void): this; once(event: "unpipe", listener: (src: Readable) => void): this;
never?
The hard-to-solve problems really come from any in contravariant positions.
Tried running this on the compiler.
commandLineParser
Array()
any[]
isArray
Array<{}>
Really don't like as never
as never
Really two usages of any that have been conflated:
The answer may just be to tell people to go through their files and return unknown.
unknown
Have a list of places any just appears:
function f({...x})
function f([,,x])
Not sure about this feature.
Some users really want a more capable unknown.
Some users really want a dynamic instead of an any.
dynamic
What about per-file strict-ness?
strict
If we did this all over, we could have considered unknown to be treated as "effectively any" for usage, still not assignable.
Can't imagine we would use this in --strict
--strict
Would we use this feature?
We'd like to get feedback from users based on the current behavior and see if it's truly paletable.
.ts
.js
#22665 #23906
checkJs
allowJsDoc
The text was updated successfully, but these errors were encountered:
strictAny
No branches or pull requests
--strictAny
#24423
Talked about this last time, but no implementation.
Now we have an implementation and data.
Came from conversation with the Hack team.
Background: problem today is that
any
is assignable in both directions.any
in a declaration file because they were lazy or just scaffolding things..d.ts
file has no way to defensively avoid assigningany
to anything else.any
- makesany
a top type.Tried running
--strictAny
on DefinitelyTypedNot on tests - tests have too much breakage.
Some things got broken - declaration files were
Much of the time it's just declaration authors being a little lazy.
any
prototype
property on generic classes withany
across.any
in derived classes.Why is
any
not assignable toRecord<string, any>
>There are some issues with signatures like
(x: any, y: any, ...zs: any[]) => any
.any
is subject to contravariant checking.never
instead ofany
.Issues with
SVGElement
not being assignable toElement
.Then there's the "covariant event emitter pattern".
never
?never
isn't very intuitiveThe hard-to-solve problems really come from
any
in contravariant positions.Tried running this on the compiler.
commandLineParser
is sloppy.Array()
always return anany[]
.isArray
is a predicate onArray<{}>
any
in the middle.commandLineParser
had a lot of questionable behavior.prototype
s of generic classes, there are some places whereany
never occurred but the type checker - for example, erased signatures.Really don't like
as never
Really two usages of
any
that have been conflated:The answer may just be to tell people to go through their files and return
unknown
.Have a list of places
any
just appears:function f({...x})
)function f([,,x])
)Not sure about this feature.
any
has become so conflated and prevalent.Some users really want a more capable
unknown
.Some users really want a
dynamic
instead of anany
.What about per-file
strict
-ness?If we did this all over, we could have considered
unknown
to be treated as "effectivelyany
" for usage, still not assignable.Can't imagine we would use this in
--strict
Would we use this feature?
We'd like to get feedback from users based on the current behavior and see if it's truly paletable.
"Loose mode" in
.ts
files vs. TypeScript in.js
files#22665
#23906
checkJs
has been instructivecheckJs
that make things different.allowJsDoc
..js
file to a.ts
file, we should offer to migrate the file.The text was updated successfully, but these errors were encountered: