Comments (5)
I can't find any TS docs about it, but it is valid - see some examples from the TS codebase itself https://github.com/search?q=repo%3Amicrosoft%2FTypeScript+declare+const&type=code
declare const
is indeed valid and documented. What I am talking about is making cohabit an import and a declare const
with the same name.
I took some time to test locally, and if the imported file exists, I get an error:
// @filename a.jts
export {}
// @filename b.js
import * as ns from "./a.js";
// ^^
// Import declaration conflicts with local declaration of 'ns'. ts(2440)
declare const ns: {
f: () => unknown
};
However, if the imported file doesn't exist (your case?), TypeScript doesn't report the error – this is likely a bug from TSC.
Thus, I think it is an error of using an identical name for an import and a declare const
.
from biome.
Got it, thanks for helping investigate, I'll also open a bug with TS about the compiler issue.
from biome.
I was not aware of this kind of declaration merging. Do you have any TypeScript resources that document this? This looks wrong to me 🤔
I could suggest using module augmentation instead:
import * as routeModule from "__SENTRY_WRAPPING_TARGET_FILE__";
declare module "__SENTRY_WRAPPING_TARGET_FILE__" {
export function GET(...args: unknown[]): unknown;
/* ... */
}
export const GET = [routeModule.GET, 'GET'];
I think it is more idiomatic in TypeScript.
from biome.
I can't find any TS docs about it, but it is valid - see some examples from the TS codebase itself https://github.com/search?q=repo%3Amicrosoft%2FTypeScript+declare+const&type=code
I agree your change feels more idomatic, but I think biome should still account for this edge case.
from biome.
I agree your change feels more idomatic, but I think biome should still account for this edge case.
While I feel the sentiment, I find it very hard to explain something that we can't document. When we create a rule, we always strive to write something that we can properly document, with references too.
If we can't document this edge case, how can we prove that what we are doing is the right way?
from biome.
Related Issues (20)
- Biome encountered an unexpected error (semantic_model/scope.rs:115:33) HOT 2
- 🐛 cli version 1.7.2 init config file schema does not exist HOT 2
- 🐛 Typo in settings for nursery rule useConsistentBuiltinInstantiation HOT 1
- Autofix on save leaves empty import
- 📎 Upgrade to `tower-lsp` 0.20 HOT 3
- 📎 Implement lint rule to require file extension on relative imports - `import/extensions` HOT 6
- 🐛 Biome --apply Command Hangs Due to Incorrect rel Attribute Recommendation HOT 4
- 🐛 Biome encountered an unexpected error HOT 1
- 🐛 internalError/panic: no entry found for key HOT 1
- 🐛 Latest version (1.7.2) keeps crashing HOT 13
- 💅 Invalid unnecessary constructor on abstract class that forwards arguments to base HOT 6
- 🐛 `no entry found for key` (crates/biome_js_semantic/src/semantic_model/scope.rs) HOT 2
- 🐛 Arrays format in package.json differs from the format the default npm one HOT 1
- 💅 `lint/style/useExportType` removes comments in multiline export statements
- 💅 useSingleCaseStatement shouldn't report break statements HOT 1
- 🐛 Biome server crash on this utility type in 1.7.2 HOT 1
- 🐛 ✖ processing panicked: no entry found for key HOT 1
- Eslint Migraition adding prefix "eslint-config-" when package have only "eslint-config" as name
- 📎 Implement property-no-unknown HOT 1
- 📎 Implement no-invalid-position-at-import-rule HOT 2
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 biome.