Comments (5)
This is intentional. There are a lot of calls like this that only work in a secure context. If you know your code is always going to run over HTTPS, it would be incredibly annoying and counterproductive if the compiler forced you do either do a null check or add a non-null assertion to every such call.
from typescript.
See also #52044 which was marked WAI.
from typescript.
Thanks for those links @fatcerberus but in my humble opinion, the "it works in secure context" argument is not much better than a "but it works on my machine" argument. Those that don't care about running in contexts where the property can be null are free to use optional chaining or non-null assertion (if they want to assert they really don't care). A single character isn't counter-productive or something that causes clutter. A false assurance on the other hand is bad for people who care.
from typescript.
“but it works on my machine”
This is a bad analogy because HTTP/HTTPS is a server-side concern and not something that would be affected by end-user configuration.
Anyway I’m just telling you the position of the TS maintainers on this - it’s not considered a bug for the reasons stated before and that’s not likely to change.
from typescript.
This issue has been marked as "Working as Intended" and has seen no recent activity. It has been automatically closed for house-keeping purposes.
from typescript.
Related Issues (20)
- Feature Request: narrow down type for `length` property of string literals & allow length constraints on func params HOT 3
- JSON.stringify can return undefined HOT 1
- add `generateTrace` to tsconfig's `compilerOptions` HOT 2
- Conditionnal return type not recognized inside the function HOT 4
- `importModuleSpecifierPreference: "non-relative"` should use self-name package imports HOT 3
- Design Meeting Notes, 8/13/2024 HOT 5
- Incorrect hover information when initializing a union-typed `const` with `never` HOT 5
- Provide a way to omit first generic parameter when it can be inferred HOT 2
- Unexpected any when using conditional type HOT 6
- KeyboardEvent: Unexpected undefined value of key on autocomplete HOT 5
- Un-initialized class fields are omitted from the emitted JS, compared to the field counterparts in JS HOT 3
- Add typeChecker API to get the inferred type arguments of call expression HOT 1
- Inconsistent Type Inference in Generic Function HOT 6
- Function type expression won't infer the rest parameter type correctly HOT 2
- transpileModule fails when declarationMap is specified HOT 6
- TypeScript can't infer type of default parameters HOT 2
- Allow type annotations in .js files in preparation for Type Annotations proposal
- ts `Move to a new file` doesn't respect `importModuleSpecifier` setting
- Refactor: move to new file does not work HOT 4
- typescript `Move to a new file` doesn't work when namespace import react
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typescript.