searchfe / searchfe/ts2php

shorthand property assigment initializer 如果是import 进来的函数,无法正确添加 namespace。

Open
#78 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted
Dominant language
TypeScript
Stars
98
Forks
20
Avg merge
5m
Merged PRs (30d)
3

Description

如下代码:

import {aaa} from './aaa'; // namespace: \someModule\
let a = {
    aaa: aaa
};

现在可以正确翻译成:

require_once(dirname(__FILE__) . '/' . "./aaa.php");
$a = array(
    "aaa" => "\someModule\aaa"
);

但是如果使用简写形式:

import {aaa} from './aaa'; // namespace: \someModule\
let a = {
    aaa
};

从 ShorthandPropertyAssignment.name 中不能查找到 import 部分,无法添加上 namespace。

require_once(dirname(__FILE__) . '/' . "./aaa.php");
$a = array(
    "aaa" => ""aaa""
);

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the handling of ShorthandPropertyAssignment.name and how imported symbols are resolved. Compare shorthand and explicit property assignment translation, and consider the issue complete when the shorthand form produces the imported namespace-qualified value, such as "\someModule\aaa", in the generated PHP.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, typescript
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.