Skip to content
New issue

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

feat: use typescript #60

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

feat: use typescript #60

wants to merge 4 commits into from

Conversation

ota-meshi
Copy link
Member

This PR changes the source code to use typescript.

I also changed it to use unbuild for building. This will allow us to provide bundled d.ts.

@ota-meshi ota-meshi requested a review from a team February 6, 2023 05:28
@codecov-commenter
Copy link

codecov-commenter commented Feb 6, 2023

Codecov Report

Attention: 13 lines in your changes are missing coverage. Please review.

Comparison is base (32b8306) 96.96% compared to head (236faa8) 97.44%.
Report is 10 commits behind head on main.

Files Patch % Lines
src/get-string-if-constant.ts 77.77% 6 Missing ⚠️
src/reference-tracker.ts 98.92% 3 Missing ⚠️
src/get-property-name.ts 95.55% 2 Missing ⚠️
src/get-static-value.ts 98.79% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #60      +/-   ##
==========================================
+ Coverage   96.96%   97.44%   +0.48%     
==========================================
  Files          13       14       +1     
  Lines        2111     2626     +515     
  Branches      396      406      +10     
==========================================
+ Hits         2047     2559     +512     
- Misses         63       66       +3     
  Partials        1        1              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

package.json Outdated Show resolved Hide resolved
.eslintrc.js Outdated Show resolved Hide resolved
src/pattern-matcher.ts Outdated Show resolved Hide resolved
@@ -49,23 +71,105 @@ function isPassThrough(node) {
}
}

export interface ReferenceTrackerOptions {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export interface ReferenceTrackerOptions {
export type ReferenceTrackerOptions = {

/**
* Options for `hasSideEffect`, optionally.
*/
export interface HasSideEffectOptions {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export interface HasSideEffectOptions {
export type HasSideEffectOptions = {

src/token-predicate.ts Outdated Show resolved Hide resolved
src/token-predicate.ts Outdated Show resolved Hide resolved
@ota-meshi
Copy link
Member Author

@MichaelDeBoey Sorry for the delay. Thank you for checking this PR.
I fixed this PR. Could you please check again?

Comment on lines +3 to +8
@eslint-community/mysticatea/eslint-comments/no-use:0,
@eslint-community/mysticatea/ts/no-unsafe-assignment:0,
@eslint-community/mysticatea/ts/no-unsafe-argument:0,
@eslint-community/mysticatea/ts/no-unsafe-return:0,
@eslint-community/mysticatea/ts/no-unsafe-member-access:0,
@eslint-community/mysticatea/ts/no-unsafe-call:0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@eslint-community/mysticatea/eslint-comments/no-use:0,
@eslint-community/mysticatea/ts/no-unsafe-assignment:0,
@eslint-community/mysticatea/ts/no-unsafe-argument:0,
@eslint-community/mysticatea/ts/no-unsafe-return:0,
@eslint-community/mysticatea/ts/no-unsafe-member-access:0,
@eslint-community/mysticatea/ts/no-unsafe-call:0,
@eslint-community/mysticatea/eslint-comments/no-use:off,
@eslint-community/mysticatea/ts/no-unsafe-assignment:off,
@eslint-community/mysticatea/ts/no-unsafe-argument:off,
@eslint-community/mysticatea/ts/no-unsafe-return:off,
@eslint-community/mysticatea/ts/no-unsafe-member-access:off,
@eslint-community/mysticatea/ts/no-unsafe-call:off,

import type * as ESTree from "estree"
export function getParent(node: ESTree.Node): ESTree.Node | null {
// eslint-disable-next-line @eslint-community/mysticatea/ts/no-unsafe-member-access
return (node as any).parent as ESTree.Node | null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we somehow get rid of the as any cast?

declare const self: typeof globalThis
declare const window: typeof globalThis

const globalObject: Record<string, any> =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use unknown instead of any
https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html#any

Suggested change
const globalObject: Record<string, any> =
const globalObject: Record<string, unknown> =

*/
function getPropertyDescriptor(object, name) {
function getPropertyDescriptor(object: any, name: number | string | symbol) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function getPropertyDescriptor(object: any, name: number | string | symbol) {
function getPropertyDescriptor(object: unknown, name: number | string | symbol) {

*/
function isGetter(object, name) {
function isGetter(object: any, name: number | string | symbol) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function isGetter(object: any, name: number | string | symbol) {
function isGetter(object: unknown, name: number | string | symbol) {

function replaceF(
matcher: PatternMatcher,
str: string,
replace: (substring: string, ...args: any[]) => string,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
replace: (substring: string, ...args: any[]) => string,
replace: (substring: string, ...args: unknown[]) => string,

[Symbol.replace](str, replacer) {
public [Symbol.replace](
str: string,
replacer: string | ((substring: string, ...args: any[]) => string),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
replacer: string | ((substring: string, ...args: any[]) => string),
replacer: string | ((substring: string, ...args: unknown[]) => string),


const IMPORT_TYPE = /^(?:Import|Export(?:All|Default|Named))Declaration$/u
const has = Function.call.bind(Object.hasOwnProperty)
const has = Function.call.bind(Object.hasOwnProperty) as (
o: any,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
o: any,
o: unknown,

const linter = new eslint.Linter()
let variable = null
let variable: any = null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let variable: any = null
let variable: unknown = null

)
},
}))
let actual: any = null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let actual: any = null
let actual: unknown = null

Copy link

This PR has been automatically closed because we haven't received a response from the original author 🙈. This automation helps keep the issue tracker clean from PRs that aren't actionable. Please reach out if you have more information for us! 🙂

@github-actions github-actions bot closed this Dec 12, 2023
@MichaelDeBoey MichaelDeBoey reopened this Dec 20, 2023
@github-actions github-actions bot removed the Stale label Dec 20, 2023
@voxpelli
Copy link
Member

voxpelli commented Mar 4, 2024

@ota-meshi Shall we continue with this PR? I reopened #150 to track whether we can readd types in a different way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants