Comments (20)
Of course, thank you!
from stc.
You have two options.
./scripts/test.sh yourTestName
will work, but if you want to reduce it further, you can copy it to tests directory of the file analyzer
from stc.
Oh, then there's Type::Optional
from stc.
Not sure. You can search for RPat::Assign
using IDE to look at possible cases.
I expect it to be one of
stc/crates/stc_ts_file_analyzer/src/analyzer/pat.rs
Lines 276 to 285 in d8b849c
stc/crates/stc_ts_file_analyzer/src/analyzer/pat.rs
Lines 316 to 374 in d8b849c
stc/crates/stc_ts_file_analyzer/src/analyzer/scope/vars.rs
Lines 158 to 217 in d8b849c
stc/crates/stc_ts_file_analyzer/src/analyzer/scope/vars.rs
Lines 275 to 291 in d8b849c
from stc.
Hey @kdy1 !
Can I take this one? I'd like to work on it
from stc.
Thanks to your comment @hyp3rflow (link π βΒ #179 (comment)).
I've also decided to double check error list in TypeScript repo and it's exactly the same (conformance tests are also identical):
- TypeScript βΒ destructuringArrayBindingPatternAndAssignment3.errors.txt
- stc - destructuringArrayBindingPatternAndAssignment3.errors.json
So tests are up-to-date
from stc.
Now I'm trying to understand how I can run one specific test and get the same output that you shared on the screenshot
Working with output
I've checked the typical flow in CONTRIBUTING.md, but it says:
Each error will contain lots of information required for debugging, with context: prefix. Read it, and if it's a wrong error, copy in to ./crates/stc_ts_file_analyzer/tests/pass.
Output is so huge, how can you work with it? Do you maybe write it to the file and read when ./scripts/check.sh
is completed? I'm running it in VSCode and it's impossible to read anything. I would really appreciate any advice here.
Running single test
So even though I couldn't get context:
when I ran ./scripts/check.sh
, I still created a file in crates/stc_ts_file_analyzer/tests/pass
.
I called it es6/destructuring/destructuringArrayBindingPatternAndAssignment3/.6.ts
βΒ in this commit https://github.com/Beraliv/stc/commit/aa917fe078694bf97e37fcb4f2d82ad6880d7584
When I run ./scripts/check.sh
, it's still running all 500 tests but not the single one that I just added
Do I miss anything?
Get the same output
As I see on the screenshot, there's a DebugContext and the error below.
Can you please navigate me what I need to do to see it as well?
from stc.
I only continued it today, as didn't have time on the weekend
I was checking the whole fn assign_without_wrapping
in crates/stc_ts_file_analyzer/src/analyzer/assign/mod.rs
to be able to understand the general idea what we match with what.
The idea of the solution in my head looks like:
- if lhs.len >= rhs.len, let's check default parameters and exclude them
- if lhs_without_default_params.len === rhs.len, good, let's move on to other existing checks
- otherwise, error as previously
I will try to come up with the solution in the PR this week
I'm sorry for being a little slow as I'm learning a lot here
from stc.
The type of arguments are correctly inferred as [any, any, any, any]
I'm still thinking whether it should be [any, any?, any?, any?]
instead? As default parameters mean that the parameter is optional. Do you have a representation for that?
At least that's what TS Playground infers for this example βΒ https://tsplay.dev/Wkk2DW
from stc.
There's a representation, but any? is any
It's exactly the same type
from stc.
There's a representation, but any? is any
It's exactly the same type
Not exactly, the example is here βΒ https://tsplay.dev/WvGJkw
type A = [any, any, any, any];
βΒ A has a fixed length, which equals to 4type B = [any, any?, any?, any?];
means tuple can be of length between 1 and 4
That's why assigning [1]
to type B will work, but won't work for type A
from stc.
@Beraliv Are you actively working on it? I'm asking this because it's a good-first-issue
from stc.
@kdy1, sorry for leaving no progress for 8 days. I struggled with the fix so wasn't sure how to proceed with it.
Is it possible you give me some hints?
I'm happy to continue with it, but if anyone already has a fix, I'm happy to let her/him do it instead of me
from stc.
Just to be transparent, that's what I have now βΒ #298
from stc.
You have two options.
./scripts/test.sh yourTestName
will work, but if you want to reduce it further, you can copy it to tests directory of the file analyzer
I can confirm that for crates/stc_ts_type_checker/tests/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment3.ts
running ./scripts/test.sh destructuringArrayBindingPatternAndAssignment3
worked for me
Thank you again for the help!
from stc.
Do you still need help?
from stc.
Do you still need help?
Let me come back to you in the evening, as I'm on the conference today.
I will explain what I try to do and where I need to be navigated
from stc.
I imagine any is implicit for function parameters so they're inferred as [any, any, any, any]
.
But as we have default parameters, I wonder if it would be possible to convert it to [any, any?, any?, any?]
.
If so, what is the best place to do it? Because for now I get elems
already with the wrong type.
I know how to do it when it will be of a different type (match l as element of elems
with Optional as you suggested above, if it's true for the rest of tuple, don't emit error - β
)
So the confusing part for me is that place for inferring type for function parameters. Can you please navigate me in the codebase so I know where to make a change?
from stc.
I keep looking at it.
Was there any change to main
branch? I pulled changes from there and I'm trying to rebuild it and I see errors:
β cargo install --path .
Installing stc v0.1.0 (/Users/beraliv/Documents/Code/stc)
Updating crates.io index
warning: unused import: `std::cell::RefCell`
--> crates/stc_utils/src/error.rs:1:5
|
1 | use std::cell::RefCell;
| ^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: unused import: `crate::panic_context`
--> crates/stc_utils/src/error.rs:3:5
|
3 | use crate::panic_context;
| ^^^^^^^^^^^^^^^^^^^^
warning: unused imports: `cell::RefCell`, `panic`, `sync::Once`
--> crates/stc_utils/src/panic_context.rs:1:11
|
1 | use std::{cell::RefCell, panic, sync::Once};
| ^^^^^^^^^^^^^ ^^^^^ ^^^^^^^^^^
warning: `stc_utils` (lib) generated 3 warnings
Compiling stc_ts_errors v0.1.0 (/Users/beraliv/Documents/Code/stc/crates/stc_ts_errors)
error[E0432]: unresolved import `crate::context::with_ctx`
--> crates/stc_ts_errors/src/lib.rs:28:5
|
28 | use crate::context::with_ctx;
| ^^^^^^^^^^^^^^^^^^^^^^^^ no `with_ctx` in `context`
warning: unused import: `std::cell::RefCell`
--> crates/stc_ts_errors/src/context.rs:1:5
|
1 | use std::cell::RefCell;
| ^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: unused import: `rnode::RNode`
--> crates/stc_ts_errors/src/debug/debugger.rs:3:5
|
3 | use rnode::RNode;
| ^^^^^^^^^^^^
warning: unused import: `stc_ts_ast_rnode::RTsType`
--> crates/stc_ts_errors/src/debug/debugger.rs:4:5
|
4 | use stc_ts_ast_rnode::RTsType;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: unused imports: `Emitter`, `Node`, `text_writer::JsWriter`
--> crates/stc_ts_errors/src/debug/debugger.rs:7:24
|
7 | use swc_ecma_codegen::{text_writer::JsWriter, Emitter, Node};
| ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^ ^^^^
error[E0599]: no method named `push` found for unit type `()` in the current scope
--> crates/stc_ts_errors/src/lib.rs:70:23
|
70 | self.contexts.push(context.to_string());
| ^^^^ method not found in `()`
error[E0599]: no method named `iter` found for unit type `()` in the current scope
--> crates/stc_ts_errors/src/lib.rs:90:34
|
90 | for ctx in self.contexts.iter().rev() {
| ^^^^ method not found in `()`
error[E0599]: no method named `push` found for unit type `()` in the current scope
--> crates/stc_ts_errors/src/lib.rs:2002:43
|
2002 | buf[idx].contexts.push(format!("duplicate: {}", e.contexts.join("\n")));
| ^^^^ method not found in `()`
error[E0599]: no method named `join` found for unit type `()` in the current scope
--> crates/stc_ts_errors/src/lib.rs:2002:84
|
2002 | buf[idx].contexts.push(format!("duplicate: {}", e.contexts.join("\n")));
| ^^^^ method not found in `()`
Some errors have detailed explanations: E0432, E0599.
For more information about an error, try `rustc --explain E0432`.
warning: `stc_ts_errors` (lib) generated 4 warnings
error: could not compile `stc_ts_errors` due to 5 previous errors; 4 warnings emitted
error: failed to compile `stc v0.1.0 (/Users/beraliv/Documents/Code/stc)`, intermediate artifacts can be found at `/Users/beraliv/Documents/Code/stc/target`
Not sure if I'm doing something wrong
from stc.
Thank you for merging my PR @kdy1!
I will keep looking at assignments and maybe raise a separate PR later this week to cover wider scope
Sorry again for taking a lot of time as I'm familiarising with the codebase and learning Rust at the same time
from stc.
Related Issues (20)
- Fix unit test: `tests/tsc/conformance/expressions/functionCalls/callWithSpread4/.1.ts`
- Improve Interface type params HOT 7
- Variable initialized with a call expression may not have correct type params inferred HOT 2
- Add a way to get the span for an interface's identifier
- stc fails to find type alias circular references HOT 1
- Different comment values in TSC CLI and test file, Which one should We trust? HOT 14
- Would you be willing to provide an STC playground? HOT 4
- Preliminary benchmarks HOT 1
- Split `Storage` into `TypeStore` and `ErrorStore`
- Source of data HOT 1
- [extra error] Type guard of form type of other should be filter string | number | boolean
- [todo]: closure or Indexing, etc. should follow the scope of where they are declared.
- [to do] implement type param indexing HOT 1
- [Meta] Unassigned gfi(good first issue)
- Timer logging should be switched to a flag. HOT 10
- Requires an actual type operation.(2322 extra error)
- Panic: `controlFlowIterationErrorsAsync.ts`(duplicate span)
- Project is officially abandoned HOT 9
- feat: implement ambient comment
- [todo]: refactoring - duplicate function call cause duplicate error at interface decl statement
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 stc.